<template>
  <div class="hello">
    {{msg}}
    <button @click="sendHandle">发送消息到原生</button>
    
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {
      msg: ''
    }
  },
  created() {
    this.$bridge.registerHandler('FtoW', (data, callback) => {
      this.msg = `从 flutter 接收 ${JSON.stringify(data)}`
      callback()
    })
  },
  methods: {
    sendHandle() {
      this.$bridge.callHandler('WtoF', {data: '发给flutter的消息'}, (data) => {
        this.msg = `从 flutter 回调 ${JSON.stringify(data)}`
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
